package AFTriangle;

public class AFTriangleProgram {
	
	public static void main(String args[]) {
		try{
			if ( args.length != 3 )
			{
				System.out.println("Invalid input");
			}
			else
			{
				classifyTriangle( Double.valueOf(args[0]), Double.valueOf(args[1]), Double.valueOf(args[2]) ); 
			}
		}
		catch(NumberFormatException e)
		{
			System.out.println("Invalid input");
		}
	}

	static void classifyTriangle(double side1, double side2, double side3) {
				
		if ( isValid(side1, side2, side3) ) {
			System.out.println("Invalid Triangle");
			return;
		}
		if ( isEquilateralTriangle(side1, side2, side3) ) {
			System.out.println("Equilateral Triangle");
		}
		
		else if ( isIsoscelesTriangle(side1, side2, side3) ) {
			if ( isRightTriangle(side1, side2, side3) )
			{
				System.out.print("Right ");
			}
			System.out.println("Isosceles Triangle");
		}
		
		else if ( isScaleneTriangle(side1, side2, side3) ) {
			if ( isRightTriangle(side1, side2, side3) )
			{
				System.out.print("Right ");
			}
			System.out.println("Scalene Triangle");
		}
		else
		{
			System.out.println("Invalid Triangle");
		}
				
	}

	static boolean isValid(double side1, double side2, double side3) {
		 if( (side1 <= (side2+side3)) || (side2 <= (side1+side3)) || (side3 <= (side1+side2) ) ) {
			 return false;
		 }
		return true;
	}

	static boolean isEquilateralTriangle(double side1, double side2, double side3) {
		if ( anyInvalidSides(side1, side2, side3) ) return false;
		else if ( side1 == side2 && side1 == side3 ) {
			return true;
		}
		return false;
	}

	static boolean isIsoscelesTriangle(double side1, double side2, double side3) {
		if ( anyInvalidSides(side1, side2, side3) ) return false;
		else if ( side1 == side2 || side1 == side3 || side2 == side3 ) {
			if ( !isEquilateralTriangle(side1, side2, side3) ) {
				return true;
			}
			return false;
		}
		return false;
	}

	static boolean isScaleneTriangle(double side1, double side2, double side3) {
		if ( anyInvalidSides(side1, side2, side3) ) return false;
		else if ( side1 != side3 && side1 != side2 && side2 != side3 ) {
			return true;
		}
		return false;
	}

	static boolean anyInvalidSides(double side1, double side2, double side3) {
		if ( side1 <= 0 || side2 <= 0 || side3 <= 0 )
			return true;
		return false;
	}

	static boolean isRightTriangle(double side1, double side2, double side3) {
		if ( Math.pow(side1, 2) + Math.pow(side2, 2) == Math.pow(side3, 2) ||
			 Math.pow(side1, 2) + Math.pow(side3, 2) == Math.pow(side2, 2) ||
			 Math.pow(side3, 2) + Math.pow(side2, 2) == Math.pow(side1, 2) ){
			return true;
		}
		return false;
	}
}
